package com.myidis.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.myidis.entity.RightRole;

public interface RightRoleMapper {
	@Select("SELECT * FROM right_role")
    @Results({
        @Result(property = "name", column = "name"),
        @Result(property = "description", column = "description")
    })
    List<RightRole> all();

    @Select("SELECT * FROM right_role WHERE id = #{id}")
    @Results({
    	@Result(property = "name", column = "name"),
        @Result(property = "description", column = "description")
    })
    RightRole getOne(int id);
    
    @Select("SELECT * FROM right_role WHERE name = #{name}")
    @Results({
    	@Result(property = "name", column = "name"),
        @Result(property = "description", column = "description")
    })
    RightRole getByName(RightRole role);

    @Insert("INSERT INTO right_role(name, description) VALUES(#{name}, #{description})")
    int insert(RightRole role);

    @Update("UPDATE right_role SET name = #{name}, description = #{description} WHERE id = #{id}")
    int update(RightRole role);

    @Delete("DELETE FROM right_role WHERE id = #{id}")
    int delete(int id);
}
